home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2008 February
/
PCWorld_2008-02_cd.bin
/
domacnost a kancelar
/
move action
/
moveaction.exe
/
mainthread.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2007-12-14
|
2KB
|
83 lines
unit mainthread;
interface
uses
shellapi, Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, clipbrd,ExtCtrls, AviCaptura, MMSystem,
Spin, JLCVideo, inifiles;
type
TMainThread = class(TThread)
private
frmOwner: TForm;
protected
procedure Execute; override;
public
constructor create(_frmOwner: TForm; _JLCVideo1: TJLCVideo);
destructor Destroy; override;
end;
implementation
uses
unit1;
{constructor}
constructor TMainThread.create(_frmOwner: TForm; _JLCVideo1: TJLCVideo);
begin
inherited create(true); // create but don't start running yet
frmOwner := _frmOwner;
end;
{destructor}
destructor TMainThread.Destroy;
begin
inherited destroy;
end;
{main thread entry point}
procedure TMainThread.Execute;
var
mainForm: TForm1;
normalFrameinterval, fastFrameinterval, fastFrameintervalPeriod, intervalToUse: integer;
movementDetected: boolean;
fastFrameIntervalExpires: DWORD;
begin
fastFrameIntervalExpires := 0;
mainForm := (frmOwner as TForm1);
with TIniFile.Create(ExtractFilePath(Application.ExeName) + '\' + confFile) do
begin
normalFrameinterval := ReadInteger('main', 'normalFrameinterval', 1000);
fastFrameinterval := ReadInteger('main', 'fastFrameinterval', 100);
fastFrameintervalPeriod := ReadInteger('main', 'fastFrameintervalPeriod', 10) * 1000;
free;
end;
repeat
movementDetected := mainForm.doMainIteration;
// if we detect movement, speed up the frame rate for a while
if movementDetected then
begin
intervalToUse := fastFrameinterval;
fastFrameIntervalExpires := GetTickCount + fastFrameintervalPeriod;
end
else if GetTickCount > fastFrameIntervalExpires then
begin
intervalToUse := normalFrameinterval;
end;
sleep(intervalToUse);
until terminated;
end;
end.